<?php
## include required files
/*******************************/
require_once '../../includefiles.php';
require_once '../../model/message.php';
require_once '../../model/users.php';
require_once '../../redirect.php';

checkUserLogin();
## Create Objects
/*******************************/
$msgObj = new Model_Message();
$userObj = new Model_Users();
/*******************************/

$userId = $_SESSION['getbids_id'];
$userDetArray = $userObj->getUserDetailsByUserId($userId);
$smarty->assign('userDetArray',$userDetArray);

$userDetArr = $userObj->getUserDetailsByUserId($userId);
$smarty->assign("userDetArr", $userDetArr);

$adminDetArr = $userObj->getUserDetailsByUserId(1);
$smarty->assign("adminDetArr", $adminDetArr);

if($_GET['id1']!='')
{
	$getmessagedetail =	$msgObj->getMessageDetailsById(base64_decode($_GET['id1']));
	$smarty->assign("getmessagedetail", $getmessagedetail);
}

if(isset($_POST['message']) && $_POST['message']!='')
{
	$msgAddArray = array();
	$msgAddArray['from_id']   = $userId; 
	$msgAddArray['to_id'] 	  = 1;
	$msgAddArray['subject']   = return_post_value($_POST['subject']);
	$msgAddArray['message']   = return_post_value($_POST['message']);
	$msgAddArray['send_date'] = getCurDate();
	$msgAddArray['label'] 	  = 'inbox';
	$msgObj->addMessage($msgAddArray); # add record for inbox
	
	$msgAddArray['label'] 	  = 'outbox';
	$msgObj->addMessage($msgAddArray); # add record for outbox
	
	
	$_SESSION['msg']="<div class='success_msg' style='margin-bottom:15px;'><span>Message Sent Successfully.</span></div>";
	header("Location: ".SITE_URL."/myaccount/mymessages");
	exit;
}
	


$active = "myaccount";
$smarty->assign("active", $active);
$subactive = "message_reply";
$smarty->assign("subactive", $subactive);

$mainmenu='2';
$smarty->assign("mainmenu",$mainmenu);

$smarty->display(TEMPLATEDIR . '/modules/myaccount/message_reply.tpl');
?>